﻿using Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DAGG.Ashx
{
    /// <summary>
    /// QrCode 的摘要说明
    /// </summary>
    public class QrCode : IHttpHandler
    {
        JsonHelper jsonHelper = new JsonHelper();
        public void ProcessRequest(HttpContext context)
        {
              string oper=context.Request.QueryString["oper"];
          
            string strResult = string.Empty;
            switch (oper)
            {
                case "QrCode":
                    strResult = CreateQrCode(context);
                    context.Response.Write(strResult);
                    break;
                case "LookImg":
                    strResult = LookImg(context);
                    context.Response.ContentType = "image/jpeg";
                    context.Response.WriteFile(strResult);
                    break;
            }
           
        }
        public string CreateQrCode(HttpContext context)
        {
            QrCodeMethod qrCode = new QrCodeMethod();
            string tiemid = context.Request.QueryString["TempId"];//只为预览效果展示
            string ImageUrl = string.Empty;
            //qrCode.CreateCode_Simple("danganguan.m12315.com/Result.aspx?tempid=" + tiemid, ref ImageUrl);
            qrCode.CreateCode_Simple("http://danganguanm.m12315.com/Origins.aspx?tempid=" + tiemid, ref ImageUrl);
            return ImageUrl;
        }
        //浏览图片
        public string LookImg(HttpContext context)
        {
            string path = context.Request.QueryString["imgParth"] + "";
            return path;

        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}